package com.yc.other.encode;

import cn.hutool.core.util.URLUtil;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * Created with IntelliJ IDEA.
 * description: url编码
 * author: YC
 * date: 2020/10/28
 * time: 20:49
 */
public class TestUrlEncode {
//    String str = "rUctYItugknBAUcWjHglbg==";
//    String str = "Ui2zJ9DZEalWSWi4UR2+Sg==";
    String str = "VyH7e78IkVKjV06/KJ1D4g==";

    public void m1() {
        /**
         * rUctYItugknBAUcWjHglbg%3D%3D
         * Ui2zJ9DZEalWSWi4UR2%2BSg%3D%3D
         * VyH7e78IkVKjV06%2FKJ1D4g%3D%3D
         */
        System.out.println(URLEncoder.encode(str));
    }

    public void m1_2() throws UnsupportedEncodingException {
        /**
         * rUctYItugknBAUcWjHglbg%3D%3D
         * Ui2zJ9DZEalWSWi4UR2%2BSg%3D%3D
         * VyH7e78IkVKjV06%2FKJ1D4g%3D%3D
         */
        System.out.println(URLEncoder.encode(str, "UTF-8"));
    }

    public void m2() {
        /**
         * rUctYItugknBAUcWjHglbg%3D%3D
         * Ui2zJ9DZEalWSWi4UR2%2BSg%3D%3D
         * VyH7e78IkVKjV06%2FKJ1D4g%3D%3D
         */
        System.out.println(URLUtil.encodeAll(str));
    }

    public static void main(String[] args) throws Exception {
        TestUrlEncode tue = new TestUrlEncode();
//        tue.m1();
//        tue.m1_2();
        tue.m2();
    }
}
